/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.uniminuto.edu.videominuto.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Juan
 */
@Entity
@Table(name = "video")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Video.findAll", query = "SELECT v FROM Video v"),
    @NamedQuery(name = "Video.findByIsan", query = "SELECT v FROM Video v WHERE v.isan = :isan"),
    @NamedQuery(name = "Video.findByIdVideo", query = "SELECT v FROM Video v WHERE v.idVideo = :idVideo"),
    @NamedQuery(name = "Video.findByTitulo", query = "SELECT v FROM Video v WHERE v.titulo = :titulo"),
    @NamedQuery(name = "Video.findByFechaProduccion", query = "SELECT v FROM Video v WHERE v.fechaProduccion = :fechaProduccion"),
    @NamedQuery(name = "Video.findByDuraVideo", query = "SELECT v FROM Video v WHERE v.duraVideo = :duraVideo")})
public class Video implements Serializable {
    private static final long serialVersionUID = 1L;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "isan")
    private String isan;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_video")
    private Integer idVideo;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 200)
    @Column(name = "titulo")
    private String titulo;
    @Basic(optional = false)
    @NotNull
    @Column(name = "fecha_produccion")
    @Temporal(TemporalType.DATE)
    private Date fechaProduccion;
    @Basic(optional = false)
    @NotNull
    @Column(name = "dura_video")
    private int duraVideo;
    @JoinTable(name = "reg_pelicula", joinColumns = {
        @JoinColumn(name = "id_video", referencedColumnName = "id_video")}, inverseJoinColumns = {
        @JoinColumn(name = "id_pelicula", referencedColumnName = "id_pelicula")})
    @ManyToMany
    private List<Pelicula> peliculaList;
    @JoinTable(name = "doblaje", joinColumns = {
        @JoinColumn(name = "id_video", referencedColumnName = "id_video")}, inverseJoinColumns = {
        @JoinColumn(name = "id_idioma_dob", referencedColumnName = "id_idioma")})
    @ManyToMany
    private List<Idioma> idiomaList;
    @JoinTable(name = "categoria_video", joinColumns = {
        @JoinColumn(name = "id_video", referencedColumnName = "id_video")}, inverseJoinColumns = {
        @JoinColumn(name = "id_categoria", referencedColumnName = "id_categoria")})
    @ManyToMany
    private List<Categoria> categoriaList;
    @JoinTable(name = "reg_serie", joinColumns = {
        @JoinColumn(name = "id_video", referencedColumnName = "id_video")}, inverseJoinColumns = {
        @JoinColumn(name = "id_serie", referencedColumnName = "id_serie")})
    @ManyToMany
    private List<Serie> serieList;
    @JoinTable(name = "subtitulo", joinColumns = {
        @JoinColumn(name = "id_video", referencedColumnName = "id_video")}, inverseJoinColumns = {
        @JoinColumn(name = "id_idioma_sub", referencedColumnName = "id_idioma")})
    @ManyToMany
    private List<Idioma> idiomaList1;
    @JoinTable(name = "reg_coleccion", joinColumns = {
        @JoinColumn(name = "id_video", referencedColumnName = "id_video")}, inverseJoinColumns = {
        @JoinColumn(name = "id_coleccion", referencedColumnName = "id_coleccion")})
    @ManyToMany
    private List<Coleccion> coleccionList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "video")
    private List<Transaccion> transaccionList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "video")
    private List<RegPersonas> regPersonasList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "video")
    private List<Calificacion> calificacionList;
    @JoinColumn(name = "id_idioma", referencedColumnName = "id_idioma")
    @ManyToOne(optional = false)
    private Idioma idIdioma;
    @JoinColumn(name = "id_formato", referencedColumnName = "id_formato")
    @ManyToOne(optional = false)
    private Formato idFormato;
    @JoinColumn(name = "id_clasificacion", referencedColumnName = "id_clasificacion")
    @ManyToOne(optional = false)
    private Clasificacion idClasificacion;

    public Video() {
    }

    public Video(Integer idVideo) {
        this.idVideo = idVideo;
    }

    public Video(Integer idVideo, String isan, String titulo, Date fechaProduccion, int duraVideo) {
        this.idVideo = idVideo;
        this.isan = isan;
        this.titulo = titulo;
        this.fechaProduccion = fechaProduccion;
        this.duraVideo = duraVideo;
    }

    public String getIsan() {
        return isan;
    }

    public void setIsan(String isan) {
        this.isan = isan;
    }

    public Integer getIdVideo() {
        return idVideo;
    }

    public void setIdVideo(Integer idVideo) {
        this.idVideo = idVideo;
    }

    public String getTitulo() {
        return titulo;
    }

    public void setTitulo(String titulo) {
        this.titulo = titulo;
    }

    public Date getFechaProduccion() {
        return fechaProduccion;
    }

    public void setFechaProduccion(Date fechaProduccion) {
        this.fechaProduccion = fechaProduccion;
    }

    public int getDuraVideo() {
        return duraVideo;
    }

    public void setDuraVideo(int duraVideo) {
        this.duraVideo = duraVideo;
    }

    @XmlTransient
    public List<Pelicula> getPeliculaList() {
        return peliculaList;
    }

    public void setPeliculaList(List<Pelicula> peliculaList) {
        this.peliculaList = peliculaList;
    }

    @XmlTransient
    public List<Idioma> getIdiomaList() {
        return idiomaList;
    }

    public void setIdiomaList(List<Idioma> idiomaList) {
        this.idiomaList = idiomaList;
    }

    @XmlTransient
    public List<Categoria> getCategoriaList() {
        return categoriaList;
    }

    public void setCategoriaList(List<Categoria> categoriaList) {
        this.categoriaList = categoriaList;
    }

    @XmlTransient
    public List<Serie> getSerieList() {
        return serieList;
    }

    public void setSerieList(List<Serie> serieList) {
        this.serieList = serieList;
    }

    @XmlTransient
    public List<Idioma> getIdiomaList1() {
        return idiomaList1;
    }

    public void setIdiomaList1(List<Idioma> idiomaList1) {
        this.idiomaList1 = idiomaList1;
    }

    @XmlTransient
    public List<Coleccion> getColeccionList() {
        return coleccionList;
    }

    public void setColeccionList(List<Coleccion> coleccionList) {
        this.coleccionList = coleccionList;
    }

    @XmlTransient
    public List<Transaccion> getTransaccionList() {
        return transaccionList;
    }

    public void setTransaccionList(List<Transaccion> transaccionList) {
        this.transaccionList = transaccionList;
    }

    @XmlTransient
    public List<RegPersonas> getRegPersonasList() {
        return regPersonasList;
    }

    public void setRegPersonasList(List<RegPersonas> regPersonasList) {
        this.regPersonasList = regPersonasList;
    }

    @XmlTransient
    public List<Calificacion> getCalificacionList() {
        return calificacionList;
    }

    public void setCalificacionList(List<Calificacion> calificacionList) {
        this.calificacionList = calificacionList;
    }

    public Idioma getIdIdioma() {
        return idIdioma;
    }

    public void setIdIdioma(Idioma idIdioma) {
        this.idIdioma = idIdioma;
    }

    public Formato getIdFormato() {
        return idFormato;
    }

    public void setIdFormato(Formato idFormato) {
        this.idFormato = idFormato;
    }

    public Clasificacion getIdClasificacion() {
        return idClasificacion;
    }

    public void setIdClasificacion(Clasificacion idClasificacion) {
        this.idClasificacion = idClasificacion;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idVideo != null ? idVideo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Video)) {
            return false;
        }
        Video other = (Video) object;
        if ((this.idVideo == null && other.idVideo != null) || (this.idVideo != null && !this.idVideo.equals(other.idVideo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "co.uniminuto.edu.videominuto.entities.Video[ idVideo=" + idVideo + " ]";
    }
    
}
